#include "mainwindow.h"

#include <QApplication>
#include <QGroupBox>
#include <QTreeWidgetItem>

#include "main.h"
#include "operate_parm.h"

struct master_state_summary master_state;
struct master_adaptor_parm_widget_summary master_adaptor_parm_widget;
struct master_adaptor_set_parm_widget_summary master_adaptor_set_parm_widget;

struct adaptor_paramter_wedget_summary adaptor_parm_summary[SLAVE_NUM];
struct adaptor_paramter_set_summary adaptor_parm_set_summary;
struct mount_widget slave_mount_widget;
struct operate_parm_widget slave_operate_parm[SLAVE_NUM];
QListWidgetItem *slave_op_parm_item[SLAVE_NUM];
QListWidgetItem *slave_ad_parm_item[SLAVE_NUM];

struct my_lineedit_summary_5 lineedit_summary_5;
struct my_lineedit_summary_6 lineedit_summary_6;

struct my_lineedit_summary_7 lineedit_summary_7;
struct my_lineedit_summary_8 lineedit_summary_8;

struct my_lineedit_summary_11 lineedit_summary_11;
struct my_lineedit_summary_12 lineedit_summary_12;

struct my_lineedit_summary_13 lineedit_summary_13;
struct my_lineedit_summary_14 lineedit_summary_14;
struct my_lineedit_summary_15 lineedit_summary_15;

struct my_lineedit_summary_18 lineedit_summary_18;

class func_widget *func_widget_summary;

QPushButton *start_pump_send;
user_textedit *my_textedit_1;
my_checkbox *show_parm_cmd_checkbox;

void init_var(void)
{
    memset(&operate_parm, 0, sizeof(operate_parm));
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    int stacklayout_count = 0;
    func_widget_summary = new func_widget(NULL);
    QListWidget *my_list = new QListWidget;
    string tmp;

    init_var();

    QStackedLayout *my_stackedlayout = new QStackedLayout;

    QWidget *page_main_1_widget = new QWidget();
    QHBoxLayout *page_main_1_layout = new QHBoxLayout();
    page_main_1_widget->setLayout(page_main_1_layout);

    QWidget *page_main_1_sub_2_widget = new QWidget();
    QVBoxLayout *page_main_1_sub_2_layout = new QVBoxLayout();

    QWidget *page1_widget = new QWidget();
    QHBoxLayout *page1_layout = new QHBoxLayout();
    page1_layout->setSpacing(1);
    page1_layout->setMargin(1);

    QWidget *page2_widget = new QWidget();
    QHBoxLayout *page2_layout = new QHBoxLayout();
    page2_widget->setLayout(page2_layout);
    page2_layout->setSpacing(1);
    page2_layout->setMargin(1);

    QWidget *page4_widget = new QWidget();
    QHBoxLayout *page4_layout = new QHBoxLayout();
    page4_widget->setLayout(page4_layout);
    page4_layout->setSpacing(1);
    page4_layout->setMargin(1);

    QHBoxLayout *master_state_layout = new QHBoxLayout();

    master_state_layout->setSpacing(1);
    master_state_layout->setMargin(1);

    QWidget *page5_widget = new QWidget();
    QHBoxLayout *page5_layout = new QHBoxLayout();
    page5_widget->setLayout(page5_layout);
    page5_layout->setSpacing(1);
    page5_layout->setMargin(1);

    QVBoxLayout *main_layout = new QVBoxLayout();
    main_layout->addLayout(my_stackedlayout);

    QHBoxLayout *my_layout = new QHBoxLayout;
    QWidget *my_widget = new QWidget;

    QVBoxLayout *main_1_layout = new QVBoxLayout();

    my_layout->addWidget(my_list);

    my_layout->addLayout(main_layout);
    my_layout->addLayout(page_main_1_sub_2_layout);
    my_layout->addLayout(main_1_layout);

    my_widget->setLayout(my_layout);

    my_textedit_1 = new user_textedit(NULL);
    my_textedit_1->textedit->setFixedWidth(300);
    page_main_1_sub_2_layout->addWidget(my_textedit_1->textedit);

    show_parm_cmd_checkbox = new my_checkbox("显示参数查询指令", 1, 0, NULL);
    page_main_1_sub_2_layout->addWidget(show_parm_cmd_checkbox);
    QPushButton *clear_textedit = new QPushButton("清空");

    QObject::connect(clear_textedit, SIGNAL(clicked(bool)), my_textedit_1, SLOT(button_clear(bool)));
    page_main_1_sub_2_layout->addWidget(clear_textedit);

    /// 集中控制器运行参数
    master_state.widget = new QWidget;
    master_state.vboxlayout = new QVBoxLayout;
    master_state.vboxlayout->setSpacing(1);
    master_state.vboxlayout->setMargin(1);
    master_state.widget->setLayout(master_state.vboxlayout);
    master_state.master_state = new my_lineedit("集中控制器状态", NULL);
    master_state.master_brake = new my_lineedit("集中控制器刹车", NULL);
    master_state.commander_comm_err = new my_lineedit("指控通信状态", NULL);
    for (unsigned int j = 0; j < sizeof(master_state) / 4 - 2; j++)
    {
        master_state.vboxlayout->addWidget(*((my_lineedit **)(&master_state.master_state + j)));
    };
    master_state_layout->addWidget(master_state.widget);

    QListWidgetItem *master_group = new QListWidgetItem("集中控制器运行参数");
    master_group->setCheckState(Qt::Checked);
    master_group->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    my_list->insertItem(stacklayout_count, master_group);
    my_stackedlayout->insertWidget(stacklayout_count, master_state.widget);
    stacklayout_count++;

    for (unsigned int i = 0; i < SLAVE_NUM; i++)
    {
        slave_operate_parm[i].widget = new QWidget;
        slave_operate_parm[i].vboxlayout = new QVBoxLayout;
        slave_operate_parm[i].vboxlayout->setSpacing(1);
        slave_operate_parm[i].vboxlayout->setMargin(1);
        slave_operate_parm[i].widget->setLayout(slave_operate_parm[i].vboxlayout);

        slave_operate_parm[i].slave_state = new my_lineedit("光源状态", NULL);
        slave_operate_parm[i].wave_length = new my_lineedit("波长", NULL);
        ;
        slave_operate_parm[i].mo1_current = new my_lineedit("预放1电流", NULL);
        slave_operate_parm[i].mo1_state = new my_lineedit("预放1状态", NULL);

        slave_operate_parm[i].mo2_current = new my_lineedit("预放2电流", NULL);
        slave_operate_parm[i].mo2_state = new my_lineedit("预放2状态", NULL);

        slave_operate_parm[i].fa1_current = new my_lineedit("主放1电流", NULL);
        slave_operate_parm[i].fa1_state = new my_lineedit("主放1状态", NULL);

        slave_operate_parm[i].fa2_current = new my_lineedit("主放2电流", NULL);
        slave_operate_parm[i].fa2_state = new my_lineedit("主放2状态", NULL);

        slave_operate_parm[i].pd1 = new my_lineedit("pd1值", NULL);
        slave_operate_parm[i].pd2 = new my_lineedit("pd2值", NULL);
        slave_operate_parm[i].pd3 = new my_lineedit("pd3值", NULL);
        slave_operate_parm[i].pd4 = new my_lineedit("pd4值", NULL);
        slave_operate_parm[i].t1 = new my_lineedit("t1值", NULL);
        slave_operate_parm[i].t2 = new my_lineedit("t2值", NULL);
        slave_operate_parm[i].t3 = new my_lineedit("t3值", NULL);
        slave_operate_parm[i].t4 = new my_lineedit("t4值", NULL);
        slave_operate_parm[i].humidity = new my_lineedit("环境湿度", NULL);
        slave_operate_parm[i].temperature = new my_lineedit("环境温度", NULL);
        slave_operate_parm[i].intensity = new my_lineedit("强光功率", NULL);
        slave_operate_parm[i].running_state = new my_lineedit("运行状态", NULL);
        slave_operate_parm[i].seed_source_state = new my_lineedit("种子源状态", NULL);
        slave_operate_parm[i].expansion_module_state = new my_lineedit("展宽模块状态", NULL);
        slave_operate_parm[i].err_code1 = new my_lineedit("故障字1", NULL);
        slave_operate_parm[i].err_code2 = new my_lineedit("故障字2", NULL);
        slave_operate_parm[i].err_code3 = new my_lineedit("故障字3", NULL);
        slave_operate_parm[i].expansion_module_id = new my_lineedit("波形", NULL);
        for (unsigned int j = 0; j < sizeof(slave_operate_parm[i]) / 4 - 2; j++)
        {
            slave_operate_parm[i].vboxlayout->addWidget(*((my_lineedit **)(&slave_operate_parm[i].slave_state + j)));
        };
    }

    for (unsigned int i = 0; i < SLAVE_NUM; i++)
    {
        tmp = "子束";
        tmp += to_string(i + 1);
        slave_op_parm_item[i] = new QListWidgetItem(tmp.c_str());
        my_list->insertItem(stacklayout_count, slave_op_parm_item[i]);
        printf("stacklayout_count = %d\n", stacklayout_count);
        my_stackedlayout->insertWidget(stacklayout_count, slave_operate_parm[i].widget);
        stacklayout_count++;
    }

    //////集中控制器适应性参数反馈
    ///
    master_adaptor_parm_widget.widget = new QWidget();
    master_adaptor_parm_widget.vboxlayout = new QVBoxLayout();
    master_adaptor_parm_widget.vboxlayout->setSpacing(1);
    master_adaptor_parm_widget.vboxlayout->setMargin(1);
    master_adaptor_parm_widget.widget->setLayout(master_adaptor_parm_widget.vboxlayout);
    master_adaptor_parm_widget.button_ada_parm = new QPushButton("适应性参数查询");

    for (unsigned int i = 0; i < SLAVE_NUM; i++)
    {
        tmp = "子束";
        tmp += to_string(i + 1);
        tmp += "挂载";
        master_adaptor_parm_widget.slave_mount[i] = new my_checkbox((char *)tmp.c_str(), 1, 0, NULL);
    }

    master_adaptor_parm_widget.brake_enable = new my_checkbox("刹车使能", 1, 0, NULL);
    master_adaptor_parm_widget.commander_comm_enable = new my_checkbox("指控通信监控使能", 1, 0, NULL);
    for (unsigned int j = 0; j < sizeof(master_adaptor_parm_widget) / 4 - 2; j++)
    {
        master_adaptor_parm_widget.vboxlayout->addWidget(*((my_lineedit **)(&(master_adaptor_parm_widget.button_ada_parm) + j)));
    }
    QObject::connect(master_adaptor_parm_widget.button_ada_parm, SIGNAL(clicked(bool)), func_widget_summary, SLOT(ada_parm_query(bool)));

    QListWidgetItem *slave_ad_group = new QListWidgetItem("集中控制器适应性参数");
    slave_ad_group->setCheckState(Qt::Checked);
    slave_ad_group->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    my_list->insertItem(stacklayout_count, slave_ad_group);
    my_stackedlayout->insertWidget(stacklayout_count, master_adaptor_parm_widget.widget);
    stacklayout_count++;

    ///////////////////////////////////////////////////////子束适应性参数查询反馈

    for (unsigned int i = 0; i < SLAVE_NUM; i++)
    {
        adaptor_parm_summary[i].widget = new QWidget();
        adaptor_parm_summary[i].vboxlayout = new QVBoxLayout();
        adaptor_parm_summary[i].vboxlayout->setSpacing(1);
        adaptor_parm_summary[i].vboxlayout->setMargin(1);
        adaptor_parm_summary[i].widget->setLayout(adaptor_parm_summary[i].vboxlayout);
        adaptor_parm_summary[i].week1_mo1_current = new my_lineedit("1级弱光mo1", NULL);
        adaptor_parm_summary[i].week1_mo2_current = new my_lineedit("1级弱光mo2", NULL);
        adaptor_parm_summary[i].week1_fa1_current = new my_lineedit("1级弱光fa1", NULL);
        adaptor_parm_summary[i].week1_fa2_current = new my_lineedit("1级弱光fa2", NULL);
        adaptor_parm_summary[i].week2_mo1_current = new my_lineedit("2级弱光mo1", NULL);
        adaptor_parm_summary[i].week2_mo2_current = new my_lineedit("2级弱光mo2", NULL);
        adaptor_parm_summary[i].week2_fa1_current = new my_lineedit("2级弱光fa1", NULL);
        adaptor_parm_summary[i].week2_fa2_current = new my_lineedit("2级弱光fa2", NULL);
        adaptor_parm_summary[i].strong_mo1_current = new my_lineedit("强光mo1", NULL);
        adaptor_parm_summary[i].strong_mo2_current = new my_lineedit("强光mo2", NULL);
        adaptor_parm_summary[i].strong_fa1_current = new my_lineedit("强光fa1", NULL);
        adaptor_parm_summary[i].strong_fa2_current = new my_lineedit("强光fa2", NULL);
        adaptor_parm_summary[i].mo1_current_over_limit = new my_lineedit("mo1上限", NULL);
        adaptor_parm_summary[i].mo2_current_over_limit = new my_lineedit("mo2上限", NULL);
        adaptor_parm_summary[i].fa_current_over_limit = new my_lineedit("fa上限", NULL);
        adaptor_parm_summary[i].can_address = new my_lineedit("can通信地址", NULL);
        adaptor_parm_summary[i].pd1_low_limit = new my_lineedit("pd1下限阈值", NULL);
        adaptor_parm_summary[i].pd2_low_limit = new my_lineedit("pd2上限阈值", NULL);
        adaptor_parm_summary[i].pd3_low_limit = new my_lineedit("pd3下限阈值", NULL);
        adaptor_parm_summary[i].pd4_low_limit = new my_lineedit("pd4下限阈值", NULL);
        adaptor_parm_summary[i].t1_over_limit = new my_lineedit("t1上限阈值", NULL);
        adaptor_parm_summary[i].t1_low_limit = new my_lineedit("t1下限阈值", NULL);
        adaptor_parm_summary[i].t2_over_limit = new my_lineedit("t2上限阈值", NULL);
        adaptor_parm_summary[i].t2_low_limit = new my_lineedit("t2下限阈值", NULL);
        adaptor_parm_summary[i].t3_over_limit = new my_lineedit("t3上限阈值", NULL);
        adaptor_parm_summary[i].t3_low_limit = new my_lineedit("t3下限阈值", NULL);
        adaptor_parm_summary[i].t4_over_limit = new my_lineedit("t4上限阈值", NULL);
        adaptor_parm_summary[i].t4_low_limit = new my_lineedit("t4下限阈值", NULL);
        adaptor_parm_summary[i].envi_temperature_over_limit = new my_lineedit("环境温度上限", NULL);
        adaptor_parm_summary[i].envi_temperature_low_limit = new my_lineedit("环境温度下限", NULL);
        adaptor_parm_summary[i].envi_humidity_over_limit = new my_lineedit("环境湿度上限", NULL);
        adaptor_parm_summary[i].wave_length = new my_lineedit("种子源波长", NULL);
        adaptor_parm_summary[i].expansion_module_id = new my_lineedit("波形设置", NULL);
        adaptor_parm_summary[i].sn = new my_lineedit("sn号", NULL);
        adaptor_parm_summary[i].brake_enable = new my_checkbox("刹车监控", 1, 0, NULL);
        adaptor_parm_summary[i].power_comm_enable = new my_checkbox("电源通信监控", 1, 0, NULL);
        adaptor_parm_summary[i].t1_enable = new my_checkbox("T1监控", 1, 0, NULL);
        adaptor_parm_summary[i].t2_enable = new my_checkbox("T2监控", 1, 0, NULL);
        adaptor_parm_summary[i].t3_enable = new my_checkbox("T3监控", 1, 0, NULL);
        adaptor_parm_summary[i].t4_enable = new my_checkbox("T4监控", 1, 0, NULL);
        adaptor_parm_summary[i].pd1_enable = new my_checkbox("PD1监控", 1, 0, NULL);
        adaptor_parm_summary[i].pd2_enable = new my_checkbox("PD2监控", 1, 0, NULL);
        adaptor_parm_summary[i].pd3_enable = new my_checkbox("PD3监控", 1, 0, NULL);
        adaptor_parm_summary[i].pd4_enable = new my_checkbox("PD4监控", 1, 0, NULL);

        adaptor_parm_summary[i].envi_temperature_enable = new my_checkbox("环境温度监控", 1, 0, NULL);
        adaptor_parm_summary[i].envi_humidity_enable = new my_checkbox("环境湿度监控", 1, 0, NULL);
        adaptor_parm_summary[i].mo_current_enable = new my_checkbox("mo电流监控", 1, 0, NULL);
        adaptor_parm_summary[i].fa_current_enable = new my_checkbox("fa电流监控", 1, 0, NULL);
        adaptor_parm_summary[i].seq_enable = new my_checkbox("时序保护监控", 1, 0, NULL);
        adaptor_parm_summary[i].master_comm_enable = new my_checkbox("集中控制器通信监控", 1, 0, NULL);

        for (unsigned int j = 0; j < sizeof(adaptor_parm_summary[j]) / 4 - 2; j++)
        {
            adaptor_parm_summary[i].vboxlayout->addWidget(*((my_lineedit **)(&(adaptor_parm_summary[i].week1_mo1_current) + j)));
        };
    }

    for (unsigned int i = 0; i < SLAVE_NUM; i++)
    {
        tmp = "子束";
        tmp += to_string(i + 1);
        slave_ad_parm_item[i] = new QListWidgetItem(tmp.c_str());
        my_list->insertItem(stacklayout_count, slave_ad_parm_item[i]);

        my_stackedlayout->insertWidget(stacklayout_count, adaptor_parm_summary[i].widget);
        stacklayout_count++;
    }

    //////////////////////////////////////////////////////////////////////////
    slave_mount_widget.widget = new QWidget;
    slave_mount_widget.vboxlayout = new QVBoxLayout;
    slave_mount_widget.vboxlayout->setSpacing(1);
    slave_mount_widget.vboxlayout->setMargin(1);
    slave_mount_widget.widget->setLayout(slave_mount_widget.vboxlayout);

    for (unsigned int i = 0; i < SLAVE_NUM; i++)
    {
        tmp = "子束";
        tmp += to_string(i + 1);
        tmp += "挂载";
        slave_mount_widget.slave_mount[i] = new my_checkbox((char *)tmp.c_str(), 1, 0, NULL);
        if (i < 28)
            slave_mount_widget.slave_mount[i]->set_clicked(1);
    }

    for (unsigned int i = 0; i < sizeof(slave_mount_widget) / 4 - 2; i++)
    {
        slave_mount_widget.vboxlayout->addWidget(*(((QWidget **)&slave_mount_widget.slave_mount) + i));
    };
    slave_mount_widget.vboxlayout->addStretch();
    main_1_layout->addWidget(slave_mount_widget.widget);

    lineedit_summary_5.widget = new QWidget;
    lineedit_summary_5.vboxlayout = new QVBoxLayout;
    lineedit_summary_5.vboxlayout->setSpacing(1);
    lineedit_summary_5.vboxlayout->setMargin(1);
    lineedit_summary_5.widget->setLayout(lineedit_summary_5.vboxlayout);
    lineedit_summary_5.button1 = new QPushButton("作战参数配置");
    lineedit_summary_5.lineedit_1 = new my_lineedit("光强", NULL);

    for (unsigned int i = 0; i < sizeof(lineedit_summary_5) / 4 - 2; i++)
    {
        lineedit_summary_5.vboxlayout->addWidget(*((my_lineedit **)(&(lineedit_summary_5.button1) + i)));
    };
    lineedit_summary_5.vboxlayout->addStretch();
    main_1_layout->addWidget(lineedit_summary_5.widget);
    QObject::connect(lineedit_summary_5.button1, SIGNAL(clicked(bool)), func_widget_summary, SLOT(fight_parm_set(bool)));

    lineedit_summary_14.widget = new QWidget;
    lineedit_summary_14.vboxlayout = new QVBoxLayout;
    lineedit_summary_14.vboxlayout->setSpacing(1);
    lineedit_summary_14.vboxlayout->setMargin(1);
    lineedit_summary_14.widget->setLayout(lineedit_summary_14.vboxlayout);

    lineedit_summary_14.button1 = new QPushButton("出强光");
    // lineedit_summary_14.button2 = new QPushButton("出红光");
    lineedit_summary_14.button3 = new QPushButton("出1级弱光");
    lineedit_summary_14.button4 = new QPushButton("出2级弱光");
    lineedit_summary_14.button5 = new QPushButton("停光");

    for (unsigned int i = 0; i < sizeof(lineedit_summary_14) / 4 - 2; i++)
    {
        lineedit_summary_14.vboxlayout->addWidget(*((my_lineedit **)(&(lineedit_summary_14.button1) + i)));
    };
    lineedit_summary_14.vboxlayout->addStretch();

    main_1_layout->addWidget(lineedit_summary_14.widget);
    QObject::connect(lineedit_summary_14.button1, SIGNAL(clicked(bool)), func_widget_summary, SLOT(output_strong_light(bool)));
    // QObject::connect(lineedit_summary_14.button2 , SIGNAL(clicked(bool)) , func_widget_summary , SLOT(output_red_light(bool)));
    QObject::connect(lineedit_summary_14.button3, SIGNAL(clicked(bool)), func_widget_summary, SLOT(output_week_1_light(bool)));
    QObject::connect(lineedit_summary_14.button4, SIGNAL(clicked(bool)), func_widget_summary, SLOT(output_week_2_light(bool)));
    QObject::connect(lineedit_summary_14.button5, SIGNAL(clicked(bool)), func_widget_summary, SLOT(stop_light(bool)));

    lineedit_summary_6.widget = new QWidget;
    lineedit_summary_6.vboxlayout = new QVBoxLayout;
    lineedit_summary_6.vboxlayout->setSpacing(1);
    lineedit_summary_6.vboxlayout->setMargin(1);
    lineedit_summary_6.widget->setLayout(lineedit_summary_6.vboxlayout);
    lineedit_summary_6.button1 = new QPushButton("复位");

    for (unsigned int i = 0; i < sizeof(lineedit_summary_6) / 4 - 2; i++)
    {
        lineedit_summary_6.vboxlayout->addWidget(*((my_lineedit **)(&(lineedit_summary_6.button1) + i)));
    };
    lineedit_summary_6.vboxlayout->addStretch();

    main_1_layout->addWidget(lineedit_summary_6.widget);
    QObject::connect(lineedit_summary_6.button1, SIGNAL(clicked(bool)), func_widget_summary, SLOT(reset(bool)));

    lineedit_summary_7.widget = new QWidget;
    lineedit_summary_7.vboxlayout = new QVBoxLayout;
    lineedit_summary_7.vboxlayout->setSpacing(1);
    lineedit_summary_7.vboxlayout->setMargin(1);
    lineedit_summary_7.widget->setLayout(lineedit_summary_7.vboxlayout);

    lineedit_summary_7.button1 = new QPushButton("热待机");
    lineedit_summary_7.button2 = new QPushButton("冷待机");

    for (unsigned int i = 0; i < sizeof(lineedit_summary_7) / 4 - 2; i++)
    {
        lineedit_summary_7.vboxlayout->addWidget(*((my_lineedit **)(&(lineedit_summary_7.button1) + i)));
    };

    lineedit_summary_7.vboxlayout->addStretch();

    main_1_layout->addWidget(lineedit_summary_7.widget);
    QObject::connect(lineedit_summary_7.button1, SIGNAL(clicked(bool)), func_widget_summary, SLOT(hot_standby(bool)));
    QObject::connect(lineedit_summary_7.button2, SIGNAL(clicked(bool)), func_widget_summary, SLOT(cold_standby(bool)));

    lineedit_summary_8.widget = new QWidget;
    lineedit_summary_8.vboxlayout = new QVBoxLayout;
    lineedit_summary_8.vboxlayout->setSpacing(1);
    lineedit_summary_8.vboxlayout->setMargin(1);
    lineedit_summary_8.widget->setLayout(lineedit_summary_8.vboxlayout);
    lineedit_summary_8.button1 = new QPushButton("撤收");
    lineedit_summary_8.button2 = new QPushButton("进入调试模式");
    lineedit_summary_8.button3 = new QPushButton("退出调试模式");

    for (unsigned int i = 0; i < sizeof(lineedit_summary_8) / 4 - 2; i++)
    {
        lineedit_summary_8.vboxlayout->addWidget(*((my_lineedit **)(&(lineedit_summary_8.button1) + i)));
    };
    lineedit_summary_8.vboxlayout->addStretch();

    main_1_layout->addWidget(lineedit_summary_8.widget);
    QObject::connect(lineedit_summary_8.button1, SIGNAL(clicked(bool)), func_widget_summary, SLOT(withdraw(bool)));
    QObject::connect(lineedit_summary_8.button2, SIGNAL(clicked(bool)), func_widget_summary, SLOT(enter_debug(bool)));
    QObject::connect(lineedit_summary_8.button3, SIGNAL(clicked(bool)), func_widget_summary, SLOT(exit_debug(bool)));

    lineedit_summary_12.widget = new QWidget;
    lineedit_summary_12.vboxlayout = new QVBoxLayout;
    lineedit_summary_12.vboxlayout->setSpacing(1);
    lineedit_summary_12.vboxlayout->setMargin(1);
    lineedit_summary_12.widget->setLayout(lineedit_summary_12.vboxlayout);
    lineedit_summary_12.button1 = new QPushButton("运行参数查询");

    for (unsigned int i = 0; i < sizeof(lineedit_summary_12) / 4 - 2; i++)
    {
        lineedit_summary_12.vboxlayout->addWidget(*((my_lineedit **)(&(lineedit_summary_12.button1) + i)));
    };
    lineedit_summary_12.vboxlayout->addStretch();
    // page3_layout->addWidget(lineedit_summary_12.widget);
    QObject::connect(lineedit_summary_12.button1, SIGNAL(clicked(bool)), func_widget_summary, SLOT(operate_parm_query(bool)));

    lineedit_summary_18.widget = new QWidget;
    lineedit_summary_18.vboxlayout = new QVBoxLayout;
    lineedit_summary_18.vboxlayout->setSpacing(1);
    lineedit_summary_18.vboxlayout->setMargin(1);

    lineedit_summary_18.widget->setLayout(lineedit_summary_18.vboxlayout);

    lineedit_summary_18.button1 = new QPushButton("进入调试模式");
    lineedit_summary_18.button2 = new QPushButton("退出调试模式");

    for (unsigned int i = 0; i < sizeof(lineedit_summary_18) / 4 - 2; i++)
    {
        lineedit_summary_18.vboxlayout->addWidget(*((my_lineedit **)(&(lineedit_summary_18.button1) + i)));
    };
    lineedit_summary_18.vboxlayout->addStretch();

    // page3_layout->addWidget(lineedit_summary_18.widget);
    QObject::connect(lineedit_summary_18.button1, SIGNAL(clicked(bool)), func_widget_summary, SLOT(enter_debug(bool)));
    QObject::connect(lineedit_summary_18.button2, SIGNAL(clicked(bool)), func_widget_summary, SLOT(exit_debug(bool)));

    lineedit_summary_13.widget = new QWidget;
    lineedit_summary_13.vboxlayout = new QVBoxLayout;
    lineedit_summary_13.vboxlayout->setSpacing(1);
    lineedit_summary_13.vboxlayout->setMargin(1);

    lineedit_summary_13.widget->setLayout(lineedit_summary_13.vboxlayout);

    lineedit_summary_13.lineedit_1 = new my_lineedit("本机(指控软件)ip", NULL);
    lineedit_summary_13.lineedit_2 = new my_lineedit("本机(指控软件)端口号", NULL);
    lineedit_summary_13.lineedit_3 = new my_lineedit("集中控制器ip", NULL);
    lineedit_summary_13.lineedit_4 = new my_lineedit("集中控制器端口号", NULL);

    lineedit_summary_13.lineedit_1->set_text("192.168.6.40");
    lineedit_summary_13.lineedit_2->set_text("6001");
    lineedit_summary_13.lineedit_3->set_text("192.168.6.60");
    lineedit_summary_13.lineedit_4->set_text("6001");

    lineedit_summary_13.button1 = new QPushButton("eth连接");
    lineedit_summary_13.button2 = new QPushButton("eth断开连接");
    lineedit_summary_13.connect = new QPushButton("建立连接");
    lineedit_summary_13.disconnect = new QPushButton("断开连接");
    lineedit_summary_13.operate_parm_upload_start = new QPushButton("开始上报状态");
    // lineedit_summary_13.alive_end = new QPushButton("停止发送心跳");

    for (unsigned int i = 0; i < sizeof(lineedit_summary_13) / 4 - 2; i++)
    {
        lineedit_summary_13.vboxlayout->addWidget(*((my_lineedit **)(&(lineedit_summary_13.lineedit_1) + i)));
    };
    lineedit_summary_13.vboxlayout->addStretch();
    main_1_layout->addWidget(lineedit_summary_13.widget);
    QObject::connect(lineedit_summary_13.button1, SIGNAL(clicked(bool)), func_widget_summary, SLOT(eth_connect(bool)));
    QObject::connect(func_widget_summary, SIGNAL(disable_can_connect_button(bool)), lineedit_summary_13.button1, SLOT(setDisabled(bool)));
    QObject::connect(lineedit_summary_13.button2, SIGNAL(clicked(bool)), func_widget_summary, SLOT(eth_disconnect(bool)));
    QObject::connect(lineedit_summary_13.button2, SIGNAL(clicked(bool)), lineedit_summary_13.button1, SLOT(setDisabled(bool)));
    QObject::connect(lineedit_summary_13.connect, SIGNAL(clicked(bool)), func_widget_summary, SLOT(udp_start_connect(bool)));
    QObject::connect(lineedit_summary_13.disconnect, SIGNAL(clicked(bool)), func_widget_summary, SLOT(udp_exec_disconnect(bool)));
    QObject::connect(lineedit_summary_13.operate_parm_upload_start, SIGNAL(clicked(bool)), func_widget_summary, SLOT(udp_start_parm_upload(bool)));

    /////////集中控制器适应性参数设置
    master_adaptor_set_parm_widget.widget = new QWidget();
    master_adaptor_set_parm_widget.vboxlayout = new QVBoxLayout();
    master_adaptor_set_parm_widget.vboxlayout->setSpacing(1);
    master_adaptor_set_parm_widget.vboxlayout->setMargin(1);
    master_adaptor_set_parm_widget.widget->setLayout(master_adaptor_set_parm_widget.vboxlayout);
    master_adaptor_set_parm_widget.button_parm_set = new QPushButton("适应性参数设置");
    master_adaptor_set_parm_widget.button_parm_store = new QPushButton("适应性参数存储");
    master_adaptor_set_parm_widget.button_parm_init = new QPushButton("适应性参数初始化");
    for (unsigned int i = 0; i < SLAVE_NUM; i++)
    {
        tmp = "子束";
        tmp += to_string(i + 1);
        tmp += "挂载";
        master_adaptor_set_parm_widget.slave_mount[i] = new my_checkbox((char *)tmp.c_str(), 1, 0, NULL);
    }

    master_adaptor_set_parm_widget.brake_enable = new my_checkbox("刹车监控", 1, 0, NULL);
    master_adaptor_set_parm_widget.commander_comm_enable = new my_checkbox("指控通信监控", 1, 0, NULL);
    for (unsigned int j = 0; j < sizeof(master_adaptor_set_parm_widget) / 4 - 2; j++)
    {
        master_adaptor_set_parm_widget.vboxlayout->addWidget(*((my_lineedit **)(&(master_adaptor_set_parm_widget.button_parm_set) + j)));
    };

    QObject::connect(master_adaptor_set_parm_widget.button_parm_set, SIGNAL(clicked(bool)), func_widget_summary, SLOT(master_adaptor_parm_set(bool)));
    QObject::connect(master_adaptor_set_parm_widget.button_parm_store, SIGNAL(clicked(bool)), func_widget_summary, SLOT(master_adaptor_parm_store(bool)));
    QObject::connect(master_adaptor_set_parm_widget.button_parm_init, SIGNAL(clicked(bool)), func_widget_summary, SLOT(master_adaptor_parm_init(bool)));

    QListWidgetItem *master_set_ad_group = new QListWidgetItem("集中控制器适应性参数设置");
    master_set_ad_group->setCheckState(Qt::Checked);
    master_set_ad_group->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    my_list->insertItem(stacklayout_count, master_set_ad_group);
    stacklayout_count++;
    my_stackedlayout->insertWidget(stacklayout_count, master_adaptor_set_parm_widget.widget);

    /////////////子束适应性参数设置
    adaptor_parm_set_summary.widget = new QWidget();
    adaptor_parm_set_summary.vboxlayout = new QVBoxLayout();
    adaptor_parm_set_summary.vboxlayout->setSpacing(1);
    adaptor_parm_set_summary.vboxlayout->setMargin(1);
    adaptor_parm_set_summary.widget->setLayout(adaptor_parm_set_summary.vboxlayout);
    adaptor_parm_set_summary.parm_set = new QPushButton("适应性参数设置");
    adaptor_parm_set_summary.parm_store = new QPushButton("适应性参数存储");
    adaptor_parm_set_summary.parm_init = new QPushButton("适应性参数初始化");
    adaptor_parm_set_summary.parm_load = new QPushButton("适应性参数加载");
    adaptor_parm_set_summary.slave_id = new my_lineedit("加载子束号", NULL);
    adaptor_parm_set_summary.week1_mo1_current = new my_lineedit("1级弱光mo1", "×0.1A", NULL);
    adaptor_parm_set_summary.week1_mo2_current = new my_lineedit("1级弱光mo2", "×0.1A", NULL);
    adaptor_parm_set_summary.week1_fa1_current = new my_lineedit("1级弱光fa1", "×0.1A", NULL);
    adaptor_parm_set_summary.week1_fa2_current = new my_lineedit("1级弱光fa2", "×0.1A", NULL);
    adaptor_parm_set_summary.week2_mo1_current = new my_lineedit("2级弱光mo1", "×0.1A", NULL);
    adaptor_parm_set_summary.week2_mo2_current = new my_lineedit("2级弱光mo2", "×0.1A", NULL);
    adaptor_parm_set_summary.week2_fa1_current = new my_lineedit("2级弱光fa1", "×0.1A", NULL);
    adaptor_parm_set_summary.week2_fa2_current = new my_lineedit("2级弱光fa2", "×0.1A", NULL);
    adaptor_parm_set_summary.strong_mo1_current = new my_lineedit("强光mo1", "×0.1A", NULL);
    adaptor_parm_set_summary.strong_mo2_current = new my_lineedit("强光mo2", "×0.1A", NULL);
    adaptor_parm_set_summary.strong_fa1_current = new my_lineedit("强光fa1", "×0.1A", NULL);
    adaptor_parm_set_summary.strong_fa2_current = new my_lineedit("强光fa2", "×0.1A", NULL);
    adaptor_parm_set_summary.mo1_current_over_limit = new my_lineedit("mo1上限", "×0.1A", NULL);
    adaptor_parm_set_summary.mo2_current_over_limit = new my_lineedit("mo2上限", "×0.1A", NULL);
    adaptor_parm_set_summary.fa_current_over_limit = new my_lineedit("fa上限", "×0.1A", NULL);

    adaptor_parm_set_summary.can_address = new my_lineedit("can通信地址", NULL);
    adaptor_parm_set_summary.pd1_low_limit = new my_lineedit("pd1下限阈值", "×20mV", NULL);
    adaptor_parm_set_summary.pd2_low_limit = new my_lineedit("pd2上限阈值", "×20mV", NULL);
    adaptor_parm_set_summary.pd3_low_limit = new my_lineedit("pd3下限阈值", "×20mV", NULL);
    adaptor_parm_set_summary.pd4_low_limit = new my_lineedit("pd4下限阈值", "×20mV", NULL);
    adaptor_parm_set_summary.t1_over_limit = new my_lineedit("t1上限阈值", "×0.1℃", NULL);
    adaptor_parm_set_summary.t1_low_limit = new my_lineedit("t1下限阈值", "×0.1℃", NULL);
    adaptor_parm_set_summary.t2_over_limit = new my_lineedit("t2上限阈值", "×0.1℃", NULL);
    adaptor_parm_set_summary.t2_low_limit = new my_lineedit("t2下限阈值", "×0.1℃", NULL);
    adaptor_parm_set_summary.t3_over_limit = new my_lineedit("t3上限阈值", "×0.1℃", NULL);
    adaptor_parm_set_summary.t3_low_limit = new my_lineedit("t3下限阈值", "×0.1℃", NULL);
    adaptor_parm_set_summary.t4_over_limit = new my_lineedit("t4上限阈值", "×0.1℃", NULL);
    adaptor_parm_set_summary.t4_low_limit = new my_lineedit("t4下限阈值", "×0.1℃", NULL);
    adaptor_parm_set_summary.envi_temperature_over_limit = new my_lineedit("环境温度上限", "×0.1℃", NULL);
    adaptor_parm_set_summary.envi_temperature_low_limit = new my_lineedit("环境温度下限", "×0.1℃", NULL);
    adaptor_parm_set_summary.envi_humidity_over_limit = new my_lineedit("环境湿度上限", "×1%", NULL);
    adaptor_parm_set_summary.wave_length = new my_lineedit("种子源波长", "×0.0001nm", NULL);
    adaptor_parm_set_summary.expansion_module_id = new my_lineedit("波形设置", NULL);
    adaptor_parm_set_summary.sn = new my_lineedit("sn号", NULL);
    adaptor_parm_set_summary.brake_enable = new my_checkbox("刹车监控", 1, 0, NULL);
    adaptor_parm_set_summary.power_comm_enable = new my_checkbox("电源通信监控", 1, 0, NULL);
    adaptor_parm_set_summary.t1_enable = new my_checkbox("T1监控", 1, 0, NULL);
    adaptor_parm_set_summary.t2_enable = new my_checkbox("T2监控", 1, 0, NULL);
    adaptor_parm_set_summary.t3_enable = new my_checkbox("T3监控", 1, 0, NULL);
    adaptor_parm_set_summary.t4_enable = new my_checkbox("T4监控", 1, 0, NULL);
    adaptor_parm_set_summary.pd1_enable = new my_checkbox("PD1监控", 1, 0, NULL);
    adaptor_parm_set_summary.pd2_enable = new my_checkbox("PD2监控", 1, 0, NULL);
    adaptor_parm_set_summary.pd3_enable = new my_checkbox("PD3监控", 1, 0, NULL);
    adaptor_parm_set_summary.pd4_enable = new my_checkbox("PD4监控", 1, 0, NULL);
    adaptor_parm_set_summary.envi_temperature_enable = new my_checkbox("环境温度监控", 1, 0, NULL);
    adaptor_parm_set_summary.envi_humidity_enable = new my_checkbox("环境湿度监控", 1, 0, NULL);
    adaptor_parm_set_summary.mo_current_enable = new my_checkbox("mo电流监控", 1, 0, NULL);
    adaptor_parm_set_summary.fa_current_enable = new my_checkbox("fa电流监控", 1, 0, NULL);
    adaptor_parm_set_summary.seq_enable = new my_checkbox("输出时序保护监控", 1, 0, NULL);
    adaptor_parm_set_summary.master_comm_enable = new my_checkbox("集中控制器通信监控", 1, 0, NULL);

    for (unsigned int j = 0; j < sizeof(adaptor_parm_set_summary) / 4 - 2; j++)
    {
        adaptor_parm_set_summary.vboxlayout->addWidget(*((my_lineedit **)(&(adaptor_parm_set_summary.parm_set) + j)));
    };

    QObject::connect(adaptor_parm_set_summary.parm_set, SIGNAL(clicked(bool)), func_widget_summary, SLOT(slave_adaptor_parm_set(bool)));
    QObject::connect(adaptor_parm_set_summary.parm_store, SIGNAL(clicked(bool)), func_widget_summary, SLOT(slave_adaptor_parm_store(bool)));
    QObject::connect(adaptor_parm_set_summary.parm_init, SIGNAL(clicked(bool)), func_widget_summary, SLOT(slave_adaptor_parm_init(bool)));
    QObject::connect(adaptor_parm_set_summary.parm_load, SIGNAL(clicked(bool)), func_widget_summary, SLOT(slave_adaptor_parm_load(bool)));

    QListWidgetItem *slave_set_ad_group = new QListWidgetItem("子束适应性参数设置");
    slave_ad_group->setCheckState(Qt::Checked);
    slave_ad_group->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    my_list->insertItem(stacklayout_count, slave_set_ad_group);
    stacklayout_count++;
    my_stackedlayout->insertWidget(stacklayout_count, adaptor_parm_set_summary.widget);

    // operate_data_update();
    // adaptor_data_update();

    w.setCentralWidget(my_widget);
    QObject::connect(my_list, SIGNAL(currentRowChanged(int)), my_stackedlayout, SLOT(setCurrentIndex(int)));
    w.setWindowTitle("3.5kw调试上位机控制程序V1.000");
    w.show();

    return a.exec();
}
